<?php
defined('IN_IA') or exit('Access Denied');
global $_W, $_GPC;
$uniacid = $_W['uniacid'];
$setting = $this->baseset($uniacid);
$jiangli = $setting['jiangli'] / 100;
$jiangli2 = $setting['jiangli2'] / 100;
$id = intval($_GPC['id']);
$queren = intval($_GPC['queren']);
if ($id > 0) {
	load()->model('mc');
	$poster = pdo_fetch("SELECT * FROM " . tablename('bsht_tbk_poster') . " WHERE uniacid = :uniacid order by id asc", array(':uniacid' => $_W['uniacid']));
	$showuser = pdo_fetch('SELECT * FROM ' . tablename($this->tableshow) . ' WHERE uniacid = :uniacid AND id = :id', array(':uniacid' => $_W['uniacid'], ':id' => $id));
	$postuser1 = pdo_fetch('SELECT * FROM ' . tablename($this->tableuser) . ' WHERE uniacid = :uniacid AND openid = :openid', array(':uniacid' => $_W['uniacid'], ':openid' => $showuser['openid']));
	$postuser2 = pdo_fetch('SELECT * FROM ' . tablename($this->tableuser) . ' WHERE uniacid = :uniacid AND uid=:uid', array(':uniacid' => $_W['uniacid'], ':uid' => $postuser1['helpid']));
	if ($queren == 1) {
		$toopenid = $postuser1['openid'];
		$touid = mc_openid2uid($toopenid);
		$status = mc_credit_update($touid, 'credit1', -$showuser['jifen'], array($touid, '删除晒单,扣除【' . $showuser['jifen'] . '】积分'));
		$mcinfo = mc_fetch($touid);
		$mc_data = array('credit1' => $mcinfo['credit1'], 'credit2' => $mcinfo['credit2'],);
		pdo_update($this->tableuser, $mc_data, array('uid' => $touid, 'uniacid' => $_W['uniacid']));
		if ($poster['cscore'] > 0) {
			$touid1 = $postuser1['helpid'];
			if ($touid1 != 0) {
				$status1 = mc_credit_update($touid1, 'credit1', -$showuser['jifen'] * $jiangli, array($touid1, '被邀请人晒单被删,扣除【' . $showuser['jifen'] * $jiangli . '】积分'));
				$mcinfo = mc_fetch($touid1);
				$mc_data = array('credit1' => $mcinfo['credit1'], 'credit2' => $mcinfo['credit2'],);
				pdo_update($this->tableuser, $mc_data, array('uid' => $touid1, 'uniacid' => $_W['uniacid']));
			}
		}
		if ($poster['pscore'] > 0) {
			$touid2 = $postuser2['helpid'];
			if ($touid2 != 0) {
				$status2 = mc_credit_update($touid2, 'credit1', -$showuser['jifen'] * $jiangli2, array($touid2, '被邀请人晒单被删,扣除【' . $showuser['jifen'] * $jiangli2 . '】积分'));
				$mcinfo = mc_fetch($touid2);
				$mc_data = array('credit1' => $mcinfo['credit1'], 'credit2' => $mcinfo['credit2'],);
				pdo_update($this->tableuser, $mc_data, array('uid' => $touid2, 'uniacid' => $_W['uniacid']));
			}
		}
	}
	$params = array();
	$params[':id'] = $id;
	$sql = 'DELETE FROM ' . tablename($this->tableshow) . ' WHERE `id`=:id';
	pdo_query($sql, $params);
	message('操作成功.', referer());
}
message('非法访问.');